<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <f:view beforePhase="#{stakeholderManagerBean.initEditBranchInfo}"/>
    </ui:define>
    <ui:define name="contentInsert">
    <h:body>
        <h:form id="formMain">
            <h1>Stakeholder Edit Branch Info</h1>
            
            <p:panel id="panel" header="Change Branch Info">
                <f:metadata>
                    <f:viewParam name ="autoConfirm" value ="#{stakeholderManagerBean.selectedBranch.fnBIOTR.autoConfirm}" />
                </f:metadata>
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />
                <h:panelGrid columns="3" cellpadding="10" >
                    <h:outputLabel for="branchname" style="font-weight: bold" value="Branch name: " />
                    <h:inputText required="true" label="Branch Name" requiredMessage="Branch name is required." id="branchname" value="#{stakeholderManagerBean.selectedBranch.name}">
                    </h:inputText>
                    <p:message for="branchname" />

                    <h:outputLabel for="address" style="font-weight: bold" value="Address: " />
                    <h:inputText required="true" label="Address" requiredMessage="Address is required." id="address" value="#{stakeholderManagerBean.selectedBranch.branchAddress.houseNumber}">
                    </h:inputText>
                    <p:message for="address" />

                    <h:outputLabel for="phoneNumber" style="font-weight: bold" value="Phone Number: " />
                    <h:inputText required="true" label="Phone Number" requiredMessage="Phone Number is required." id="phoneNumber" value="#{stakeholderManagerBean.selectedBranch.contactNumber}">
                    </h:inputText>
                    <p:message for="phoneNumber" />

                    <p:commandButton value="AutoConfirm" disabled="#{stakeholderManagerBean.selectedBranch.fnBIOTR.autoConfirm}"  action="StakeholderEditBranchInfo?faces-redirect=true" ajax="true">
                        <f:param name="autoConfirm" value="true" />
                    </p:commandButton>

                    <p:commandButton value="ManualConfirm" disabled="#{!stakeholderManagerBean.selectedBranch.fnBIOTR.autoConfirm}" action="StakeholderEditBranchInfo?faces-redirect=true" ajax="true">
                        <f:param name="autoConfirm" value="false" />
                    </p:commandButton>

                    <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                    <h:outputLabel for="percentConfirm" style="font-weight: bold" value="PercentConfirm: " />
                    <h:inputText disabled="#{stakeholderManagerBean.selectedBranch.fnBIOTR.autoConfirm}" required="#{stakeholderManagerBean.selectedBranch.fnBIOTR.autoConfirm}" label="PercentConfirm" requiredMessage="Phone Number is required." id="percentConfirm" value="#{stakeholderManagerBean.selectedBranch.fnBIOTR.percentManualConfirm}">
                    </h:inputText>

                    <h:outputLabel for="blank" style="font-weight: bold" value=""/>
                    <h:outputLabel for="eatingTime" style="font-weight: bold" value="Estimate Eating Time: " />
                    <h:inputText label="Phone Number" id="eatingTime" value="#{stakeholderManagerBean.selectedBranch.fnBIOTR.eatingTime}">
                    </h:inputText>
                    
                </h:panelGrid>
                <p:commandButton id="btn" value="Save Branch Info" update="panel" actionListener="#{stakeholderManagerBean.editBranchInfo}" ajax="true" />
            </p:panel>
        </h:form>
    </h:body>
    </ui:define>
</ui:composition>
